#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>
#include <dirent.h>
int main(int argc, char**argv)
{
    DIR* dir = opendir(argv[1]);
    if(dir == NULL)
    {
        perror("open dir error:");
        return -1;
    }
   
    while(1)
    {
        struct dirent*d = readdir(dir);
        if(d == NULL)
        {   
            if(errno != 0)
                perror("readdir error");
            break;
        }
        printf("%s\n", d->d_name);    
    }


    closedir(dir);
}